home *** CD-ROM | disk | FTP | other *** search
- Path: Rezonet.net!news
- From: ray@ultimate-tech.com (Ray Dunn)
- Newsgroups: comp.lang.c
- Subject: Re: Basic Question on SWITCH
- Date: 29 Jan 1996 03:46:27 GMT
- Organization: Ultimate Technographics Inc.
- Message-ID: <4ehfuj$166g@ns.RezoNet.NET>
- References: <4e4cu4$95f@vixen.cso.uiuc.edu> <4e8p6m$n8q@ns.RezoNet.NET> <TANMOY.96Jan26162346@qcd.lanl.gov>
- NNTP-Posting-Host: 204.19.230.7
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- In referenced article, Tanmoy Bhattacharya says...
- >
- >In article <3108ED49.987@cmt.lpr.mail.carel.fi> Ari Lukumies
- ><aril@cmt.lpr.mail.carel.fi> writes:
- ><snip>
- > if (strchr("0123456789", a))
- > ... /* It was a digit, do something */
- >
- >A special case for digits:
- >
- >if ((unsigned)(a-'0')<10)
- > /* It _is_ a digit, do something */
- >
- >But then what is wrong with isdigit?
-
- Indeed. In the general case there is no guarantee that all the digits
- are consecutive as they are in ASCII, so the use of isdigit is the only
- portable way to go, although the strchr example works fine too, if
- slowly.
-
- [As a matter of interest, MS 'C' uses a character table with bits
- defining all the various character types. isdigit etc. uses this
- table. MS provides profiling functions which allows the customization
- of this table]
- --
- Ray Dunn (opinions are my own) | Phone: (514) 938 9050
- Montreal | Phax : (514) 938 5225
- ray@ultimate-tech.com | Home : (514) 630 3749
-
-